﻿Imports System.Net.Mail

Public Class Form1
    '######################## - Deklaration des Email-Clients - '########################
    Public Sub sendmail()
        Dim emailmessage As MailMessage = New MailMessage
        emailmessage.From = New MailAddress(MetroTextBox1.Text)
        emailmessage.To.Add("kontakt@ef2a.de")
        emailmessage.Subject = MetroTextBox2.Text
        emailmessage.Body = MetroTextBox3.Text
        emailmessage.Priority = MailPriority.Normal
        Dim smtp As New SmtpClient("smtp.ef2a.de")
        Dim basicauthentificationinfo As New System.Net.NetworkCredential("et40@ef2a.de", "tsetnrsdjur6nzb6zrbnz")

        smtp.Credentials = basicauthentificationinfo

        Try
            smtp.Send(emailmessage)
            MsgBox("Die Email wurde erfolgreich abgesendet", MsgBoxStyle.Information, "Absenden Erfolgreich!")
        Catch ex As Exception
            MsgBox("Fehler beim Senden", MsgBoxStyle.Critical, "Fehler")
        End Try
    End Sub
    '######################## - Erzeugt den Border-Shadow - '########################
    Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
        Get
            Const DROPSHADOW = &H20000
            Dim cParam As CreateParams = MyBase.CreateParams
            cParam.ClassStyle = cParam.ClassStyle Or DROPSHADOW
            Return cParam
        End Get
    End Property
    '######################## - Deklariert Start- & Dragposition - '########################
    Dim MyStartPosition As Point
    Dim MyDragPosition As Point

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        '######################## - Tab-Anzeige einstellen - '########################
        Dim speed As Integer = MetroTabControl1.Speed : MetroTabControl1.Speed = 20
        For i As Integer = 0 To MetroTabControl1.TabPages.Count
            MetroTabControl1.SelectedIndex = i
        Next
        MetroTabControl1.SelectedIndex = 0 : MetroTabControl1.Speed = speed

    End Sub



    Private Sub Button2_Click(sender As Object, e As EventArgs)
        Form3.Show()
    End Sub

    Private Sub MetroControlBox1_Click(sender As Object, e As EventArgs) Handles MetroControlBox1.Click
        MetroControlBox1.BoxMaximize = False
    End Sub

    '######################## - Speichert die neue Position bei Bewegung - '########################
    Private Sub MetroPieChart1_MouseDown(sender As Object, e As MouseEventArgs) Handles MetroPieChart1.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            MyStartPosition = Me.Location
            MyDragPosition = Me.PointToScreen(New Point(e.X, e.Y))
        End If
    End Sub

    Private Sub MetroLabel2_MouseDown(sender As Object, e As MouseEventArgs) Handles MetroLabel2.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            MyStartPosition = Me.Location
            MyDragPosition = Me.PointToScreen(New Point(e.X, e.Y))
        End If
    End Sub

    '######################## - Gibt dem Fenster die neue Position - '########################
    Private Sub MetroPieChart1_MouseMove(sender As Object, e As MouseEventArgs) Handles MetroPieChart1.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Dim CursorPosition As Point = Me.PointToScreen(New Point(e.X, e.Y))
            Me.Location = New Point(MyStartPosition.X + CursorPosition.X - MyDragPosition.X, _
              MyStartPosition.Y + CursorPosition.Y - MyDragPosition.Y)
        End If
    End Sub
    Private Sub MetroLabel2_MouseMove(sender As Object, e As MouseEventArgs) Handles MetroLabel2.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Dim CursorPosition As Point = Me.PointToScreen(New Point(e.X, e.Y))
            Me.Location = New Point(MyStartPosition.X + CursorPosition.X - MyDragPosition.X, _
              MyStartPosition.Y + CursorPosition.Y - MyDragPosition.Y)
        End If
    End Sub

    '######################## - ANFANG PURI Aktionen - '########################
    Private Sub MetroNumeric1_Click(sender As Object, e As EventArgs)
        If MetroCheckCircle4.Checked Then
            PURI()
        End If
    End Sub

    Private Sub MetroNumeric2_Click(sender As Object, e As EventArgs)
        If MetroCheckCircle4.Checked Then
            PURI()
        End If
    End Sub

    Private Sub MetroNumeric3_Click(sender As Object, e As EventArgs)
        If MetroCheckCircle4.Checked Then
            PURI()
        End If
    End Sub

    Private Sub MetroNumeric4_Click(sender As Object, e As EventArgs)
        If MetroCheckCircle4.Checked Then
            PURI()
        End If
    End Sub

    Private Sub MetroButton1_Click(sender As Object, e As EventArgs) Handles MetroButton1.Click
        PURI()
    End Sub

    '######################## - ENDE PURI Aktionen - '########################

    Private Sub MetroButton2_Click(sender As Object, e As EventArgs) Handles MetroButton2.Click
        sendmail()
    End Sub

    Private Sub MetroTextBox3_Click(sender As Object, e As EventArgs) Handles MetroTextBox3.Click

    End Sub



    Private Sub MetroButton3_Click(sender As Object, e As EventArgs) Handles MetroButton3.Click
        MetroTabControl1.ColorScheme.BackColorTabPage = Color.White
        MetroPieChart1.BackColor = Color.White
        MetroControlBox1.BackColor = Color.White
    End Sub

    Private Sub TabPage5_Click(sender As Object, e As EventArgs) Handles TabPage5.Click

    End Sub
End Class
